import time

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

# 1.创建驱动对象
service = Service("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
driver = webdriver.Chrome(service=service)

# 2.打开浏览器
driver.get("https://www.baidu.com/")
driver.maximize_window()
driver.add_cookie({"name": "BDUSS","value": "ktidVdGaHpYeDU2MzNKMGt1SjNIVzlXN3ZiQjJvZnh-SlItY21vMG9LNFM2YzluSUFBQUFBJCQAAAAAAAAAAAEAAABResVcNjY2NrXazuW087XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABJcqGcSXKhnU"})
time.sleep(2)
driver.refresh()

# 4.3s后关闭
time.sleep(3)

# 5.关闭驱动对象
driver.close()